package com.esri.core.map;

import com.esri.core.internal.util.g;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.Map;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.MappingJsonFactory;
import org.codehaus.jackson.map.ObjectMapper;

/* loaded from: classes.dex */
public class RasterFunction implements Serializable {
    private static final String e = "rasterFunction";
    private static final String f = "rasterFunctionArguments";
    private static final String g = "variableName";
    private static final long serialVersionUID = 1;
    String a;
    String b;
    Map<String, Object> c;
    String d;

    public RasterFunction() {
    }

    public RasterFunction(RasterFunction rasterFunction) {
        if (rasterFunction != null) {
            this.a = rasterFunction.a;
            this.b = rasterFunction.b;
            this.d = rasterFunction.d;
        }
    }

    public String getFunctionName() {
        return this.a;
    }

    public void setFunctionName(String str) {
        this.a = str;
    }

    public String getArguments() {
        return this.b;
    }

    public void setArguments(String str) {
        this.b = str;
    }

    public Map<String, Object> getArgumentsAsMap() {
        return this.c;
    }

    public void setArgumentsAsMap(Map<String, Object> map) {
        this.c = map;
    }

    public String getVariableName() {
        return this.d;
    }

    public void setVariableName(String str) {
        this.d = str;
    }

    public static RasterFunction fromJson(JsonParser jsonParser) throws JsonParseException, IOException {
        if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
            return null;
        }
        RasterFunction rasterFunction = new RasterFunction();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if (e.equals(currentName)) {
                rasterFunction.a = jsonParser.getText();
            } else if (f.equals(currentName)) {
                rasterFunction.b = new ObjectMapper().readTree(jsonParser).toString();
            } else if (g.equals(currentName)) {
                rasterFunction.d = jsonParser.getText();
            }
        }
        return rasterFunction;
    }

    public String toJson() throws JsonGenerationException, IOException {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator createJsonGenerator = new MappingJsonFactory().createJsonGenerator(stringWriter);
        createJsonGenerator.writeStartObject();
        String str = this.a;
        if (str != null && str.length() > 0) {
            createJsonGenerator.writeStringField(e, this.a);
        }
        Map<String, Object> map = this.c;
        if (map != null && map.size() > 0) {
            createJsonGenerator.writeFieldName(f);
            new ObjectMapper().writeValue(createJsonGenerator, this.c);
        } else if (g.b(this.b)) {
            createJsonGenerator.writeFieldName(f);
            createJsonGenerator.writeRawValue(this.b);
        }
        if (g.b(this.d)) {
            createJsonGenerator.writeStringField(g, this.d);
        }
        createJsonGenerator.writeEndObject();
        createJsonGenerator.close();
        return stringWriter.getBuffer().toString();
    }

    public int hashCode() {
        String str = this.b;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        Map<String, Object> map = this.c;
        int hashCode2 = (hashCode + (map == null ? 0 : map.hashCode())) * 31;
        String str2 = this.a;
        int hashCode3 = (hashCode2 + (str2 == null ? 0 : str2.hashCode())) * 31;
        String str3 = this.d;
        return hashCode3 + (str3 != null ? str3.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            RasterFunction rasterFunction = (RasterFunction) obj;
            String str = this.b;
            if (str == null) {
                if (rasterFunction.b != null) {
                    return false;
                }
            } else if (!str.equals(rasterFunction.b)) {
                return false;
            }
            Map<String, Object> map = this.c;
            if (map == null) {
                if (rasterFunction.c != null) {
                    return false;
                }
            } else if (!map.equals(rasterFunction.c)) {
                return false;
            }
            String str2 = this.a;
            if (str2 == null) {
                if (rasterFunction.a != null) {
                    return false;
                }
            } else if (!str2.equals(rasterFunction.a)) {
                return false;
            }
            String str3 = this.d;
            if (str3 == null) {
                if (rasterFunction.d != null) {
                    return false;
                }
            } else if (!str3.equals(rasterFunction.d)) {
                return false;
            }
            return true;
        }
        return false;
    }

    public String toString() {
        return "RasterFunction [functionName=" + this.a + ", arguments=" + this.b + ", mapArguments=" + this.c + ", variableName=" + this.d + "]";
    }
}
